package com.jy.adscm.operation.aftersales.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.jy.adscm.bean.system.JyUser;
import com.jy.adscm.operation.aftersales.bean.BaseQuery;
import com.jy.adscm.operation.aftersales.bean.ShAppVersion;
import com.jy.adscm.operation.aftersales.mapper.mysql.ShAppVersionMapper;
import com.jy.adscm.operation.aftersales.service.ShAppVersionService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.jy.adscm.system.mapper.mysql.JyUserMapper;
import com.jy.adscm.utils.AdscmBaseUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 售后程序版本控制 服务实现类
 * </p>
 *
 * @author zyl
 * @since 2020-06-15
 */
@Service
public class ShAppVersionServiceImpl extends ServiceImpl<ShAppVersionMapper, ShAppVersion> implements ShAppVersionService {
     @Autowired
    JyUserMapper jyUserMapper;
    @Override
    public Page<ShAppVersion> select(BaseQuery baseQuery) {
         Page<ShAppVersion> page =new Page<>(baseQuery.getCurrentPage(),baseQuery.getPageSize());
        Wrapper<ShAppVersion> wrapper=new EntityWrapper<>();
         page=super.selectPage(page,wrapper);
         page.setTotal(selectCount(wrapper));
        List<ShAppVersion> records = page.getRecords();
        for (ShAppVersion record : records) {
            if (AdscmBaseUtils.getInstance().isNotEmpty(record.getCreator(),null)){
                JyUser jyUser = jyUserMapper.selectById(record.getCreator());
                record.setCreatorName(jyUser.getName());
            }
        }
        page.setTotal(super.selectCount(wrapper));
        return page;
    }
}
